﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBMigrator.Core.DbObjects.Data.Update;
using Rhino.Mocks;
using StructureMap;
using Xunit;

namespace DBMigrator.Core.Tests.DbObjects.Data
{
    public class SetValueTests
    {
        private readonly IAdditionalSet additionalSet;

        public SetValueTests()
        {
            additionalSet = MockRepository.GenerateMock<IAdditionalSet>();
            ObjectFactory.Inject(additionalSet);
        }

        [Fact]
        public void AdditionalSetShouldDefaultToNull()
        {
            Assert.Null(new SetValue<object>().AdditionalSet);
        }

        [Fact]
        public void EqualToShouldSetValue()
        {
            var value = StringUtil.Random();
            var setValue = new SetValue<string>();
            setValue.EqualTo(value);
            Assert.Equal(value, setValue.Value);
        }

        [Fact]
        public void EqualToShouldSetAdditionalSet()
        {
            var setValue = new SetValue<string>();
            setValue.EqualTo("value");
            Assert.Equal(additionalSet, setValue.AdditionalSet);
        }

        [Fact]
        public void EqualToShouldReturnAdditionalSet()
        {
            var setValue = new SetValue<string>();
            var result = setValue.EqualTo("value");
            Assert.Equal(setValue.AdditionalSet, result);
        }
    }
}
